import { defineStore } from 'pinia'

export const useMenuStore = defineStore('menu', {
    state: () => ({
        isCollapse: false,
        currentMenuIndex: '0-0',
        menu: [],
        submenu: {},
        historyRoute: []
    }),

    actions: {
        // 替换原 mutation SAVE_MENU
        saveMenu(menu) {
            this.menu = menu
        },

        // 替换原 mutation TOGGLE_MENU
        toggleMenu(isCollapse) {
            this.isCollapse = isCollapse
        },

        // 替换原 mutation CLICK_MENU
        clickMenu(index) {
            this.currentMenuIndex = index
        },

        // 替换原 mutation SAVE_HISTORY_ROUTE
        saveHistoryRoute(historyRoute) {
            this.historyRoute = historyRoute
        }
    }
})